import java.util.Random;


public class numberone 
{
	public static int num = 5;
	public static int crutch = 0;
	public static int howmuch(int x,int y,int arr [][])
	{
		int count = 0;
		if(x+1<num && y+2<num && arr[y+2][x+1] == 0){count++;}
		if(x+2<num && y+1<num && arr[y+1][x+2] == 0){count++;}
		if(y-2>=0 && x+1<num && arr[y-2][x+1] == 0){count++;}
		if(y-1>=0 && x+2<num && arr[y-1][x+2] == 0){count++;}
		if(x-1>=0 && y+2<num && arr[y+2][x-1] == 0){count++;}
		if(x-2>=0 && y+1<num && arr[y+1][x-2] == 0){count++;}
		if(x-1>=0 && y-2>=0 && arr[y-2][x-1] == 0){count++;}
		if(x-2>=0 && y-1>=0 && arr[y-1][x-2] == 0){count++;}
		return count;
	}

	public static int quatrefoil(int x,int y,int arr [][])
	{
		int[] Arr = {10,10,10,10,10,10,10,10};
		if(x+1<num && y+2<num && arr[y+2][x+1] == 0){Arr[0] = howmuch(x+1,y+2,arr);}
		if(x+2<num && y+1<num && arr[y+1][x+2] == 0){Arr[1] = howmuch(x+2,y+1,arr);}
		if(y-2>=0 && x+1<num && arr[y-2][x+1] == 0){Arr[2] = howmuch(x+1,y-2,arr);}
		if(y-1>=0 && x+2<num && arr[y-1][x+2] == 0){Arr[3] = howmuch(x+2,y-1,arr);}
		if(x-1>=0 && y+2<num && arr[y+2][x-1] == 0){Arr[4] = howmuch(x-1,y+2,arr);}
 		if(x-2>=0 && y+1<num && arr[y+1][x-2] == 0){Arr[5] = howmuch(x-2,y+1,arr);}
		if(x-1>=0 && y-2>=0 && arr[y-2][x-1] == 0){Arr[6] = howmuch(x-1,y-2,arr);}
		if(x-2>=0 && y-1>=0 && arr[y-1][x-2] == 0){Arr[7] = howmuch(x-2,y-1,arr);}
		int min = 10;
		int cp = 10;
		for(int i = 0;i < 8;i++)
		{
			if(cp > Arr[i] && Arr[i] != 10)
			{
				cp = Arr[i];
				min = i;
				//if(cp == 0)
					//min = 10;
			}
		}
		return min;
	}
	
	public static void main(String[] args)
	{
		int[][] arr = new int[num][num];
		for(int i = 0;i < num;i++)
		{
			for(int j = 0;j < num;j++)
			{
				arr[i][i] = 0;
			}
		}

		int x,y;
		x = new Random(System.currentTimeMillis()).nextInt(num);
		System.out.println(x);
		y = new Random(System.currentTimeMillis()).nextInt(num);
		//int count = 0;
		System.out.println(y);
		arr[y][x]++;
		int pa = 11;
		while(pa != 10)
		{
			for(int i = 0;i < 5;i++)
			{
				for(int j = 0;j < 4;j++)
				{
					System.out.print(arr[i][j]);
				}
				System.out.println(arr[i][4]);
			}
			System.out.println(7);
			pa = quatrefoil(x,y,arr);
			if(pa == 0) {x=x+1;y=y+2;}
			if(pa == 1) {x=x+2;y=y+1;}
			if(pa == 2) {x=x+1;y=y-2;}
			if(pa == 3) {x=x+2;y=y-1;}
			if(pa == 4) {x=x-1;y=y+2;}
			if(pa == 5) {x=x-2;y=y+1;}
			if(pa == 6) {x=x-1;y=y-2;}
			if(pa == 7) {x=x-2;y=y-1;}
			arr[y][x]++;
			crutch++;
			int c = 0;
			for(int i = 0;i < num;i++)
				for(int j = 0;j < num;j++)
				{
					if(arr[i][j] == 0)
						c++;
						
				}
			if((crutch > 24 && c > 0) || (pa == 10 && c > 0))
			{
				pa = 11;
				crutch = 0;
				x = new Random(System.currentTimeMillis()).nextInt(num);
				y = new Random(System.currentTimeMillis()).nextInt(num);
				for(int i = 0;i < num;i++)
					for(int j = 0;j < num;j++)
					{
						arr[i][j] = 0;
					}	
				
			}
			c = 0;
			for(int i = 0;i < num;i++)
				for(int j = 0;j < num;j++)
				{
					if(arr[i][j] == 0)
						c++;
						
				}
			if(c == 0)
				continue;
			System.out.println(c);
			System.out.println(crutch);
			System.out.print(x);System.out.print(" ");System.out.println(y);
			
		}
//		System.out.println(x);
//		System.out.println(y);
		
	}
}
